package com.ai.bitcoin.weixin.template;

import com.ai.bitcoin.constant.CommonConstant;
import com.ai.bitcoin.util.DateUtil;
import com.google.common.collect.Maps;

import java.util.Date;
import java.util.Map;

public class NewsAnnoPriceTemplate extends BaseTemplate {

    private final String templateId = "y_zC9rMMfhMuWG6NxY43_aQJDG8hUh_37E2jDOz9GpU";

    //    {{first.DATA}}
//        认证姓名：{{keyword1.DATA}}
//        认证套餐：{{keyword2.DATA}}
//        认证状态：{{keyword3.DATA}}
//        生成时间：{{keyword4.DATA}}
//        {{remark.DATA}}
    @Override
    public Map<String, Object> buildParameterMap(Map<String, Object> request) {
        Map<String,Object> resp = Maps.newHashMap();
        resp.put("touser", request.get("touser"));
        resp.put("template_id", templateId);
        resp.put("url", request.get("url"));
        Map<String,Object> dataMap = Maps.newHashMap();
        dataMap.put("first", buildDataMap(String.valueOf(request.get("first"))));
        dataMap.put("keyword1", buildDataMap(String.valueOf(request.get("keyword1"))));
        dataMap.put("keyword2", buildDataMap(String.valueOf(request.get("keyword2"))));
        dataMap.put("keyword3", buildDataMap("已发送"));
        dataMap.put("keyword4", buildDataMap(DateUtil.toDateStr(new Date(), CommonConstant.TIME_PATTERN)));
        if(request.get("remark") != null) {
            dataMap.put("remark", buildDataMap(String.valueOf(request.get("remark"))));
        }
        resp.put("data", dataMap);
        return resp;
    }

}
